ComponentOne Zip for UWP
Zip for UWP Task-Based Help / Using Passwords to Protect Zip Files
In This Topic
    Using Passwords to Protect Zip Files
    In This Topic

    To create password-protected zip files, set the C1ZipFile.Password property to a non-empty string before creating any entries. Each entry may have its own password. For example:

    Visual Basic
    Copy Code
    Dim zip As New C1ZipFile()
    zip.Password = "password"
    zip.Entries.Add(someFile)
    

    C#
    Copy Code
    C1ZipFile zip = new C1ZipFile();
    zip.Password = "password";
    zip.Entries.Add(someFile);
    

    To extract this entry later, the C1ZipFile.Password property must be set to the same value in effect when the entry was added. For example:

    Visual Basic
    Copy Code
    ' Will fail, password not set.
    zip.Password = ""
    zip.Entries.Extract(someFile)
    ' Will fail, wrong password.
    zip.Password = "pass"
    zip.Entries.Extract(someFile)
    ' Will succeed.
    zip.Password = "password"
    zip.Entries.Extract(someFile)
    

    C#
    Copy Code
    // Will fail, password not set.
    zip.Password = "";
    zip.Entries.Extract(someFile);
    // Will fail, wrong password.
    zip.Password = "pass";
    zip.Entries.Extract(someFile);
    // Will succeed.
    zip.Password = "password";
    zip.Entries.Extract(someFile);
    
    See Also